package cc.mcyx.ychat.controller.fans

import cc.mcyx.ychat.model.UserFans
import cc.mcyx.ychat.service.impl.UserFansService
import cc.mcyx.ychat.vo.request.page.SearchPage
import com.mybatisflex.core.paginate.Page
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("api/fans")
@Api("关系", tags = ["关系相关"])
class FansController {
    @Autowired
    lateinit var userFansService: UserFansService

    @PostMapping("follow/{followUid}")
    @ApiOperation("关注一个用户")
    @ApiParam(name = "followUid", value = "关注用户uid")
    fun follow(@PathVariable followUid: Int): Boolean {
        return userFansService.follow(followUid)
    }

    @GetMapping("myFollow")
    @ApiOperation("获取我的关注")
    fun getFollow(@Validated page: SearchPage): Page<UserFans> {
        return userFansService.getFollow(page)
    }

    @GetMapping("myFans")
    @ApiOperation("获取我的粉丝")
    fun getMyFans(@Validated page: SearchPage): Page<UserFans> {
        return userFansService.getFollow(page)
    }
}